#include "Polarization.h"

#include <cmath>

Polarization::Polarization(Layer mag,Layer pol)
{
  costheta=mag.getMag().dotProduct(pol.getMag());
}

Polarization::~Polarization()
{

}

double Polarization::Slonczewski(Layer mag)
{
  QTextStream cout(stdout,QIODevice::WriteOnly);
  double P=mag.getPolarization();
  //cout<<"p="<<P<<"cos="<<costheta<<endl;
  double g=-4+(pow((1+P),3)*(3+costheta)/(4*pow(P,1.5)));
  //cout<<"1/g="<<g<<endl;
  return 1/g;  
}

double Polarization::Xiao(NewParameters params)
{
  double qplus=params.getPolarization()["qplus"];
  double qminus=params.getPolarization()["qminus"];
  double b0=params.getPolarization()["b0"];
  double b1=params.getPolarization()["b1"];
  double polarization=qplus/(b0+b1*costheta)-qminus/(b0-b1*costheta);
  return polarization;
}
